﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Word;

namespace PV_Performance_Report
{
    class Report_handler
    {
        public Report_handler(string path, string result_path)
        {
            m_path = path;
            m_result_path = result_path;
            m_ds = new Data_Set();
        }

        public Data_Set GetDataSet()
        {
            return m_ds;
        }

        public int combine_files(string patten, string dst_file)
        {
            string[] file_list = Directory.GetFiles(m_path, patten, SearchOption.TopDirectoryOnly);
            if (file_list == null || file_list.Length == 0)
                return -1;

            StringBuilder sb = new StringBuilder();
            try
            {
                for (int i = 0; i < file_list.Length; i++)
                {
                    string tmp = "";
                    if (i == 0)
                    {
                        tmp = File.ReadAllText(file_list[i], Encoding.Default).Trim();
                    }
                    else
                    {
                        string tmp_with_title = File.ReadAllText(file_list[i], Encoding.Default);
                        tmp = tmp_with_title.Substring(tmp_with_title.IndexOf(")") + 1).Trim();
                    }
                    sb.Append(tmp + "\n");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
                return -1;
            }
            File.WriteAllText(dst_file, sb.ToString(), Encoding.Default);
            return 0;
        }

        public int modify_time_csv(string src_file, string dst_file, CommenDefine.File_Name_e filename_e)
        {
            StringBuilder sb = new StringBuilder();
            string[] lines = File.ReadAllLines(src_file);

            try
            {
                switch (filename_e)
                {
                    case CommenDefine.File_Name_e.PROAGENT:
                    case CommenDefine.File_Name_e.TEST_CONSOLE_COMMAND:
                        {
                            string tmp_str = "";
                            string rep_time_str = "";
                            double rep_time = 0;
                            for (int i = 0; i < lines.Length; i++)
                            {
                                if (i == 0)
                                {
                                    lines[0] = lines[0].Replace("msec", "sec");
                                    sb.Append(lines[0] + "\n");
                                    continue;
                                }
                                tmp_str = Regex.Replace(lines[i], @".*T", "");
                                rep_time_str = tmp_str.Substring(tmp_str.IndexOf(",") + 1);
                                rep_time = Convert.ToDouble(rep_time_str) / 1000;
                                tmp_str = Regex.Replace(tmp_str, @",.*", "," + rep_time.ToString("f2"));
                                sb.Append(tmp_str + "\n");
                            }
                        }
                        break;
                    case CommenDefine.File_Name_e.TEST_CONSOLE_EVENT:
                    case CommenDefine.File_Name_e.SVR_COLLECT:
                    case CommenDefine.File_Name_e.DB_COLLECT:
                    case CommenDefine.File_Name_e.POLL_TABLE_COUNT:
                    case CommenDefine.File_Name_e.TRIGGER_RULE:
                        {
                            string tmp_str = "";
                            for (int i = 0; i < lines.Length; i++)
                            {
                                if (i == 0)
                                {
                                    sb.Append(lines[0] + "\n");
                                    continue;
                                }
                                tmp_str = Regex.Replace(lines[i], @".*T", "");
                                sb.Append(tmp_str + "\n");
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
                return -1;
            }
            File.WriteAllText(dst_file, sb.ToString(), Encoding.Default);
            return 0;
        }

        public int gen_excel(string src_file, string dst_file, CommenDefine.File_Name_e filename_e)
        {

            Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbooks workbooks = excel.Workbooks;
            Missing miss = Missing.Value;
            Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(src_file);
            Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;
            //Microsoft.Office.Interop.Excel.Range cell = null;

            excel.ScreenUpdating = false; //关屏幕更新
            excel.Visible = false; //禁止显示excel
            excel.DisplayAlerts = false; //禁止警告

            int row_count = worksheet.UsedRange.Rows.Count;
            int col_count = worksheet.UsedRange.Columns.Count;

            Microsoft.Office.Interop.Excel.Range range_time;
            Microsoft.Office.Interop.Excel.Range range_rep;

            try
            {
                switch (filename_e)
                {
                    case CommenDefine.File_Name_e.PROAGENT:
                    case CommenDefine.File_Name_e.TEST_CONSOLE_COMMAND:
                        {
                            range_time = worksheet.get_Range("A2", "A" + row_count);
                            range_time.NumberFormat = "h:mm:ss.000";
                            range_rep = worksheet.get_Range("B2", "B" + row_count);
                            range_rep.NumberFormat = "0.00";

                            Microsoft.Office.Interop.Excel.Range chartRange = null;
                            //AB
                            Microsoft.Office.Interop.Excel.Chart chart1 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A", "B:B");
                            chart1.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart1.Legend.Position = XlLegendPosition.xlLegendPositionBottom;
                            
                            //avge and max
                            worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Formula = "=SUBTOTAL(1,B2:B" + row_count + ")";
                            worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Formula = "=SUBTOTAL(4,B2:B" + row_count + ")";
                            
                            //export chart pic
                            if (filename_e == CommenDefine.File_Name_e.TEST_CONSOLE_COMMAND)
                            {
                                m_ds.avg_command_responsetime = worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Text.ToString();
                                m_ds.max_command_responsetime = worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Text.ToString();
                                //chart1.Export(m_result_path + @"\TEST_CONSOLE_COMMAND_chart1.jpg", "jpg", miss);
                            }
                            else
                            {
                                m_ds.avg_agent_responsetime = worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Text.ToString();
                                m_ds.max_agent_responsetime = worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Text.ToString();
                                //chart1.Export(m_result_path + @"\PROAGENT_chart1.jpg", "jpg", miss);
                            }
                        }
                        break;
                    case CommenDefine.File_Name_e.TRIGGER_RULE:
                        {
                            range_time = worksheet.get_Range("A2", "A" + row_count);
                            range_time.NumberFormat = "h:mm:ss.000";
                            range_rep = worksheet.get_Range("F2", "F" + row_count);
                            range_rep.NumberFormat = "0.00";

                            Microsoft.Office.Interop.Excel.Range chartRange = null;
                            //AF
                            Microsoft.Office.Interop.Excel.Chart chart1 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, F:F", Missing.Value);
                            chart1.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart1.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //avge and max
                            worksheet.get_Range("F" + (row_count + 1), "F" + (row_count + 1)).Formula = "=SUBTOTAL(1,F2:F" + row_count + ")";
                            worksheet.get_Range("F" + (row_count + 2), "F" + (row_count + 2)).Formula = "=SUBTOTAL(4,F2:F" + row_count + ")";
                            m_ds.avg_trigger_time_server_time = worksheet.get_Range("F" + (row_count + 1), "F" + (row_count + 1)).Text.ToString();
                            m_ds.max_trigger_time_server_time = worksheet.get_Range("F" + (row_count + 2), "F" + (row_count + 2)).Text.ToString();
                        }
                        break;
                    case CommenDefine.File_Name_e.TEST_CONSOLE_EVENT:
                        {
                            range_time = worksheet.get_Range("A2", "A" + row_count);
                            range_time.NumberFormat = "h:mm:ss.000";
                            range_rep = worksheet.get_Range("B2", "B" + row_count);
                            range_rep.NumberFormat = "0.00";
                            range_rep = worksheet.get_Range("C2", "C" + row_count);
                            range_rep.NumberFormat = "0.00";

                            Microsoft.Office.Interop.Excel.Range chartRange = null;
                            //AB
                            Microsoft.Office.Interop.Excel.Chart chart1 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, B:B", Missing.Value);
                            chart1.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart1.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //AC
                            Microsoft.Office.Interop.Excel.Chart chart2 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, C:C", Missing.Value);
                            chart2.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart2.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //avge and max
                            worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Formula = "=SUBTOTAL(1,B2:B" + row_count + ")";
                            worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Formula = "=SUBTOTAL(4,B2:B" + row_count + ")";
                            m_ds.avg_event_console_agent = worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Text.ToString();
                            m_ds.max_event_console_agent = worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Formula = "=SUBTOTAL(1,C2:C" + row_count + ")";
                            worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Formula = "=SUBTOTAL(4,C2:C" + row_count + ")";
                            m_ds.avg_event_console_svr = worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Text.ToString();
                            m_ds.max_event_console_svr = worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Text.ToString();

                            //export chart pic
                            //chart1.Export(m_result_path + @"\TEST_CONSOLE_EVENT_chart1.jpg", "jpg", miss);
                            //chart2.Export(m_result_path + @"\TEST_CONSOLE_EVENT_chart2.jpg", "jpg", miss);
                        }
                        break;
                    case CommenDefine.File_Name_e.POLL_TABLE_COUNT:
                        {
                            range_time = worksheet.get_Range("A2", "A" + row_count);
                            range_time.NumberFormat = "h:mm:ss.000";

                            worksheet.get_Range("H1", "K" + row_count).AutoFilter(1, ">0", XlAutoFilterOperator.xlAnd, "<=1000", false);
                            worksheet.get_Range("H1", "K" + row_count).AutoFilter(2, ">0", XlAutoFilterOperator.xlAnd, "<=1000", false);
                            worksheet.get_Range("H1", "K" + row_count).AutoFilter(3, ">0", XlAutoFilterOperator.xlAnd, "<=1000", false);
                            worksheet.get_Range("H1", "K" + row_count).AutoFilter(4, ">0", XlAutoFilterOperator.xlAnd, "<=1000", false);

                            Microsoft.Office.Interop.Excel.Range chartRange = null;
                            //ABC
                            Microsoft.Office.Interop.Excel.Chart chart1 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A", "C:C");
                            chart1.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart1.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //AHI
                            Microsoft.Office.Interop.Excel.Chart chart2 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, H:H, I:I", Missing.Value);
                            chart2.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart2.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //AJK
                            Microsoft.Office.Interop.Excel.Chart chart3 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, J:J, K:K", Missing.Value);
                            chart3.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart3.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //avge and max
                            worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Formula = "=SUBTOTAL(1,B2:B" + row_count + ")";
                            worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Formula = "=SUBTOTAL(4,B2:B" + row_count + ")";
                            m_ds.avg_poll_eventstore_count = worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Text.ToString();
                            m_ds.max_poll_eventstore_count = worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Formula = "=SUBTOTAL(1,C2:C" + row_count + ")";
                            worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Formula = "=SUBTOTAL(4,C2:C" + row_count + ")";
                            m_ds.avg_poll_pmeventstore_count = worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Text.ToString();
                            m_ds.max_poll_pmeventstore_count = worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("H" + (row_count + 1), "H" + (row_count + 1)).Formula = "=SUBTOTAL(1,H2:H" + row_count + ")";
                            worksheet.get_Range("H" + (row_count + 2), "H" + (row_count + 2)).Formula = "=SUBTOTAL(4,H2:H" + row_count + ")";
                            m_ds.avg_poll_eventstore_produced = worksheet.get_Range("H" + (row_count + 1), "H" + (row_count + 1)).Text.ToString();
                            m_ds.max_poll_eventstore_produced = worksheet.get_Range("H" + (row_count + 2), "H" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("I" + (row_count + 1), "I" + (row_count + 1)).Formula = "=SUBTOTAL(1,I2:I" + row_count + ")";
                            worksheet.get_Range("I" + (row_count + 2), "I" + (row_count + 2)).Formula = "=SUBTOTAL(4,I2:I" + row_count + ")";
                            m_ds.avg_poll_eventstore_consumed = worksheet.get_Range("I" + (row_count + 1), "I" + (row_count + 1)).Text.ToString();
                            m_ds.max_poll_eventstore_consumed = worksheet.get_Range("I" + (row_count + 2), "I" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("J" + (row_count + 1), "J" + (row_count + 1)).Formula = "=SUBTOTAL(1,J2:J" + row_count + ")";
                            worksheet.get_Range("J" + (row_count + 2), "J" + (row_count + 2)).Formula = "=SUBTOTAL(4,J2:J" + row_count + ")";
                            m_ds.avg_poll_pmeventstore_produced = worksheet.get_Range("J" + (row_count + 1), "J" + (row_count + 1)).Text.ToString();
                            m_ds.max_poll_pmeventstore_produced = worksheet.get_Range("J" + (row_count + 2), "J" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("K" + (row_count + 1), "K" + (row_count + 1)).Formula = "=SUBTOTAL(1,K2:K" + row_count + ")";
                            worksheet.get_Range("K" + (row_count + 2), "K" + (row_count + 2)).Formula = "=SUBTOTAL(4,K2:K" + row_count + ")";
                            m_ds.avg_poll_pmeventstore_consumed = worksheet.get_Range("K" + (row_count + 1), "K" + (row_count + 1)).Text.ToString();
                            m_ds.max_poll_pmeventstore_consumed = worksheet.get_Range("K" + (row_count + 2), "K" + (row_count + 2)).Text.ToString();

                            //export chart pic
                            //chart1.Export(m_result_path + @"\POLL_TABLE_COUNT_chart1.jpg", "jpg", miss);
                            //chart2.Export(m_result_path + @"\POLL_TABLE_COUNT_chart2.jpg", "jpg", miss);
                            //chart3.Export(m_result_path + @"\POLL_TABLE_COUNT_chart3.jpg", "jpg", miss);
                        }
                        break;
                    case CommenDefine.File_Name_e.SVR_COLLECT:
                        {
                            range_time = worksheet.get_Range("A2", "A" + row_count);
                            range_time.NumberFormat = "h:mm:ss.000";

                            Microsoft.Office.Interop.Excel.Range chartRange = null;
                            //ABC
                            Microsoft.Office.Interop.Excel.Chart chart1 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, B:B, C:C", Missing.Value);
                            chart1.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart1.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //ADN
                            Microsoft.Office.Interop.Excel.Chart chart2 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, D:D, N:N", Missing.Value);
                            chart2.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart2.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //AOSW-AA-AE percent-processor-time
                            Microsoft.Office.Interop.Excel.Chart chart3 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, O:O, S:S, W:W, AA:AA, AE:AE", Missing.Value);
                            chart3.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart3.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //APTX-AB-AF mem-used
                            Microsoft.Office.Interop.Excel.Chart chart4 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, P:P, T:T, X:X, AB:AB, AF:AF", Missing.Value);
                            chart4.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart4.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //AQUY-AC-AG working-set
                            Microsoft.Office.Interop.Excel.Chart chart5 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, Q:Q, U:U, Y:Y, AC:AC, AG:AG", Missing.Value);
                            chart5.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart5.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //ARVZ-AD-AH working-set-peak
                            Microsoft.Office.Interop.Excel.Chart chart6 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, R:R, V:V, Z:Z, AD:AD, AH:AH", Missing.Value);
                            chart6.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart6.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //A-BG-BK java_percent_processor_time
                            Microsoft.Office.Interop.Excel.Chart chart7 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, BG:BG, BK:BK", Missing.Value);
                            chart7.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart7.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //A-BH-BL java_mem_used
                            Microsoft.Office.Interop.Excel.Chart chart8 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, BH:BH, BL:BL", Missing.Value);
                            chart8.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart8.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //avge and max
                            worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Formula = "=SUBTOTAL(1,B2:B" + row_count + ")";
                            worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Formula = "=SUBTOTAL(4,B2:B" + row_count + ")";
                            m_ds.avg_server_percent_processor_time = worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_percent_processor_time = worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Formula = "=SUBTOTAL(1,C2:C" + row_count + ")";
                            worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Formula = "=SUBTOTAL(4,C2:C" + row_count + ")";
                            m_ds.avg_server_percent_mem_used = worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_percent_mem_used = worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("D" + (row_count + 1), "D" + (row_count + 1)).Formula = "=SUBTOTAL(1,D2:D" + row_count + ")";
                            worksheet.get_Range("D" + (row_count + 2), "D" + (row_count + 2)).Formula = "=SUBTOTAL(4,D2:D" + row_count + ")";
                            m_ds.avg_server_percent_disk_time = worksheet.get_Range("D" + (row_count + 1), "D" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_percent_disk_time = worksheet.get_Range("D" + (row_count + 2), "D" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("N" + (row_count + 1), "N" + (row_count + 1)).Formula = "=SUBTOTAL(1,N2:N" + row_count + ")";
                            worksheet.get_Range("N" + (row_count + 2), "N" + (row_count + 2)).Formula = "=SUBTOTAL(4,N2:N" + row_count + ")";
                            m_ds.avg_server_disk_transfer_per_sec = worksheet.get_Range("N" + (row_count + 1), "N" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_disk_transfer_per_sec = worksheet.get_Range("N" + (row_count + 2), "N" + (row_count + 2)).Text.ToString();



                            worksheet.get_Range("O" + (row_count + 1), "O" + (row_count + 1)).Formula = "=SUBTOTAL(1,O2:O" + row_count + ")";
                            worksheet.get_Range("O" + (row_count + 2), "O" + (row_count + 2)).Formula = "=SUBTOTAL(4,O2:O" + row_count + ")";
                            m_ds.avg_server_agm_percent_processor_time = worksheet.get_Range("O" + (row_count + 1), "O" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_agm_percent_processor_time = worksheet.get_Range("O" + (row_count + 2), "O" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("S" + (row_count + 1), "S" + (row_count + 1)).Formula = "=SUBTOTAL(1,S2:S" + row_count + ")";
                            worksheet.get_Range("S" + (row_count + 2), "S" + (row_count + 2)).Formula = "=SUBTOTAL(4,S2:S" + row_count + ")";
                            m_ds.avg_server_dm_percent_processor_time = worksheet.get_Range("S" + (row_count + 1), "S" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_dm_percent_processor_time = worksheet.get_Range("S" + (row_count + 2), "S" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("W" + (row_count + 1), "W" + (row_count + 1)).Formula = "=SUBTOTAL(1,W2:W" + row_count + ")";
                            worksheet.get_Range("W" + (row_count + 2), "W" + (row_count + 2)).Formula = "=SUBTOTAL(4,W2:W" + row_count + ")";
                            m_ds.avg_server_pm_percent_processor_time = worksheet.get_Range("W" + (row_count + 1), "W" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_pm_percent_processor_time = worksheet.get_Range("W" + (row_count + 2), "W" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AA" + (row_count + 1), "AA" + (row_count + 1)).Formula = "=SUBTOTAL(1,AA2:AA" + row_count + ")";
                            worksheet.get_Range("AA" + (row_count + 2), "AA" + (row_count + 2)).Formula = "=SUBTOTAL(4,AA2:AA" + row_count + ")";
                            m_ds.avg_server_jm_percent_processor_time = worksheet.get_Range("AA" + (row_count + 1), "AA" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_jm_percent_processor_time = worksheet.get_Range("AA" + (row_count + 2), "AA" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AE" + (row_count + 1), "AE" + (row_count + 1)).Formula = "=SUBTOTAL(1,AE2:AE" + row_count + ")";
                            worksheet.get_Range("AE" + (row_count + 2), "AE" + (row_count + 2)).Formula = "=SUBTOTAL(4,AE2:AE" + row_count + ")";
                            m_ds.avg_server_fm_percent_processor_time = worksheet.get_Range("AE" + (row_count + 1), "AE" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_fm_percent_processor_time = worksheet.get_Range("AE" + (row_count + 2), "AE" + (row_count + 2)).Text.ToString();



                            worksheet.get_Range("P" + (row_count + 1), "P" + (row_count + 1)).Formula = "=SUBTOTAL(1,P2:P" + row_count + ")";
                            worksheet.get_Range("P" + (row_count + 2), "P" + (row_count + 2)).Formula = "=SUBTOTAL(4,P2:P" + row_count + ")";
                            m_ds.avg_server_agm_mem_used_mbytes = worksheet.get_Range("P" + (row_count + 1), "P" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_agm_mem_used_mbytes = worksheet.get_Range("P" + (row_count + 2), "P" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("T" + (row_count + 1), "T" + (row_count + 1)).Formula = "=SUBTOTAL(1,T2:T" + row_count + ")";
                            worksheet.get_Range("T" + (row_count + 2), "T" + (row_count + 2)).Formula = "=SUBTOTAL(4,T2:T" + row_count + ")";
                            m_ds.avg_server_dm_mem_used_mbytes = worksheet.get_Range("T" + (row_count + 1), "T" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_dm_mem_used_mbytes = worksheet.get_Range("T" + (row_count + 2), "T" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("X" + (row_count + 1), "X" + (row_count + 1)).Formula = "=SUBTOTAL(1,X2:X" + row_count + ")";
                            worksheet.get_Range("X" + (row_count + 2), "X" + (row_count + 2)).Formula = "=SUBTOTAL(4,X2:X" + row_count + ")";
                            m_ds.avg_server_pm_mem_used_mbytes = worksheet.get_Range("X" + (row_count + 1), "X" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_pm_mem_used_mbytes = worksheet.get_Range("X" + (row_count + 2), "X" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AB" + (row_count + 1), "AB" + (row_count + 1)).Formula = "=SUBTOTAL(1,AB2:AB" + row_count + ")";
                            worksheet.get_Range("AB" + (row_count + 2), "AB" + (row_count + 2)).Formula = "=SUBTOTAL(4,AB2:AB" + row_count + ")";
                            m_ds.avg_server_jm_mem_used_mbytes = worksheet.get_Range("AB" + (row_count + 1), "AB" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_jm_mem_used_mbytes = worksheet.get_Range("AB" + (row_count + 2), "AB" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AF" + (row_count + 1), "AF" + (row_count + 1)).Formula = "=SUBTOTAL(1,AF2:AF" + row_count + ")";
                            worksheet.get_Range("AF" + (row_count + 2), "AF" + (row_count + 2)).Formula = "=SUBTOTAL(4,AF2:AF" + row_count + ")";
                            m_ds.avg_server_fm_mem_used_mbytes = worksheet.get_Range("AF" + (row_count + 1), "AF" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_fm_mem_used_mbytes = worksheet.get_Range("AF" + (row_count + 2), "AF" + (row_count + 2)).Text.ToString();



                            worksheet.get_Range("Q" + (row_count + 1), "Q" + (row_count + 1)).Formula = "=SUBTOTAL(1,Q2:Q" + row_count + ")";
                            worksheet.get_Range("Q" + (row_count + 2), "Q" + (row_count + 2)).Formula = "=SUBTOTAL(4,Q2:Q" + row_count + ")";
                            m_ds.avg_server_agm_working_set = worksheet.get_Range("Q" + (row_count + 1), "Q" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_agm_working_set = worksheet.get_Range("Q" + (row_count + 2), "Q" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("U" + (row_count + 1), "U" + (row_count + 1)).Formula = "=SUBTOTAL(1,U2:U" + row_count + ")";
                            worksheet.get_Range("U" + (row_count + 2), "U" + (row_count + 2)).Formula = "=SUBTOTAL(4,U2:U" + row_count + ")";
                            m_ds.avg_server_dm_working_set = worksheet.get_Range("U" + (row_count + 1), "U" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_dm_working_set = worksheet.get_Range("U" + (row_count + 2), "U" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("Y" + (row_count + 1), "Y" + (row_count + 1)).Formula = "=SUBTOTAL(1,Y2:Y" + row_count + ")";
                            worksheet.get_Range("Y" + (row_count + 2), "Y" + (row_count + 2)).Formula = "=SUBTOTAL(4,Y2:Y" + row_count + ")";
                            m_ds.avg_server_pm_working_set = worksheet.get_Range("Y" + (row_count + 1), "Y" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_pm_working_set = worksheet.get_Range("Y" + (row_count + 2), "Y" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AC" + (row_count + 1), "AC" + (row_count + 1)).Formula = "=SUBTOTAL(1,AC2:AC" + row_count + ")";
                            worksheet.get_Range("AC" + (row_count + 2), "AC" + (row_count + 2)).Formula = "=SUBTOTAL(4,AC2:AC" + row_count + ")";
                            m_ds.avg_server_jm_working_set = worksheet.get_Range("AC" + (row_count + 1), "AC" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_jm_working_set = worksheet.get_Range("AC" + (row_count + 2), "AC" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AG" + (row_count + 1), "AG" + (row_count + 1)).Formula = "=SUBTOTAL(1,AG2:AG" + row_count + ")";
                            worksheet.get_Range("AG" + (row_count + 2), "AG" + (row_count + 2)).Formula = "=SUBTOTAL(4,AG2:AG" + row_count + ")";
                            m_ds.avg_server_fm_working_set = worksheet.get_Range("AG" + (row_count + 1), "AG" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_fm_working_set = worksheet.get_Range("AG" + (row_count + 2), "AG" + (row_count + 2)).Text.ToString();



                            worksheet.get_Range("R" + (row_count + 1), "R" + (row_count + 1)).Formula = "=SUBTOTAL(1,R2:R" + row_count + ")";
                            worksheet.get_Range("R" + (row_count + 2), "R" + (row_count + 2)).Formula = "=SUBTOTAL(4,R2:R" + row_count + ")";
                            m_ds.avg_server_agm_working_set_peak = worksheet.get_Range("R" + (row_count + 1), "R" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_agm_working_set_peak = worksheet.get_Range("R" + (row_count + 2), "R" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("V" + (row_count + 1), "V" + (row_count + 1)).Formula = "=SUBTOTAL(1,V2:V" + row_count + ")";
                            worksheet.get_Range("V" + (row_count + 2), "V" + (row_count + 2)).Formula = "=SUBTOTAL(4,V2:V" + row_count + ")";
                            m_ds.avg_server_dm_working_set_peak = worksheet.get_Range("V" + (row_count + 1), "V" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_dm_working_set_peak = worksheet.get_Range("V" + (row_count + 2), "V" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("Z" + (row_count + 1), "Z" + (row_count + 1)).Formula = "=SUBTOTAL(1,Z2:Z" + row_count + ")";
                            worksheet.get_Range("Z" + (row_count + 2), "Z" + (row_count + 2)).Formula = "=SUBTOTAL(4,Z2:Z" + row_count + ")";
                            m_ds.avg_server_pm_working_set_peak = worksheet.get_Range("Z" + (row_count + 1), "Z" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_pm_working_set_peak = worksheet.get_Range("Z" + (row_count + 2), "Z" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AD" + (row_count + 1), "AD" + (row_count + 1)).Formula = "=SUBTOTAL(1,AD2:AD" + row_count + ")";
                            worksheet.get_Range("AD" + (row_count + 2), "AD" + (row_count + 2)).Formula = "=SUBTOTAL(4,AD2:AD" + row_count + ")";
                            m_ds.avg_server_jm_working_set_peak = worksheet.get_Range("AD" + (row_count + 1), "AD" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_jm_working_set_peak = worksheet.get_Range("AD" + (row_count + 2), "AD" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("AH" + (row_count + 1), "AH" + (row_count + 1)).Formula = "=SUBTOTAL(1,AH2:AH" + row_count + ")";
                            worksheet.get_Range("AH" + (row_count + 2), "AH" + (row_count + 2)).Formula = "=SUBTOTAL(4,AH2:AH" + row_count + ")";
                            m_ds.avg_server_fm_working_set_peak = worksheet.get_Range("AH" + (row_count + 1), "AH" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_fm_working_set_peak = worksheet.get_Range("AH" + (row_count + 2), "AH" + (row_count + 2)).Text.ToString();



                            worksheet.get_Range("BG" + (row_count + 1), "BG" + (row_count + 1)).Formula = "=SUBTOTAL(1,BG2:BG" + row_count + ")";
                            worksheet.get_Range("BG" + (row_count + 2), "BG" + (row_count + 2)).Formula = "=SUBTOTAL(4,BG2:BG" + row_count + ")";
                            m_ds.avg_server_java_admin_server_percent_processor_time = worksheet.get_Range("BG" + (row_count + 1), "BG" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_admin_server_percent_processor_time = worksheet.get_Range("BG" + (row_count + 2), "BG" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("BK" + (row_count + 1), "BK" + (row_count + 1)).Formula = "=SUBTOTAL(1,BK2:BK" + row_count + ")";
                            worksheet.get_Range("BK" + (row_count + 2), "BK" + (row_count + 2)).Formula = "=SUBTOTAL(4,BK2:BK" + row_count + ")";
                            m_ds.avg_server_java_self_monitor_percent_processor_time = worksheet.get_Range("BK" + (row_count + 1), "BK" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_self_monitor_percent_processor_time = worksheet.get_Range("BK" + (row_count + 2), "BK" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("BH" + (row_count + 1), "BH" + (row_count + 1)).Formula = "=SUBTOTAL(1,BH2:BH" + row_count + ")";
                            worksheet.get_Range("BH" + (row_count + 2), "BH" + (row_count + 2)).Formula = "=SUBTOTAL(4,BH2:BH" + row_count + ")";
                            m_ds.avg_server_java_admin_server_mem_used_mbytes = worksheet.get_Range("BH" + (row_count + 1), "BH" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_admin_server_mem_used_mbytes = worksheet.get_Range("BH" + (row_count + 2), "BH" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("BL" + (row_count + 1), "BL" + (row_count + 1)).Formula = "=SUBTOTAL(1,BL2:BL" + row_count + ")";
                            worksheet.get_Range("BL" + (row_count + 2), "BL" + (row_count + 2)).Formula = "=SUBTOTAL(4,BL2:BL" + row_count + ")";
                            m_ds.avg_server_java_self_monitor_mem_used_mbytes = worksheet.get_Range("BL" + (row_count + 1), "BL" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_self_monitor_mem_used_mbytes = worksheet.get_Range("BL" + (row_count + 2), "BL" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("BI" + (row_count + 1), "BI" + (row_count + 1)).Formula = "=SUBTOTAL(1,BI2:BI" + row_count + ")";
                            worksheet.get_Range("BI" + (row_count + 2), "BI" + (row_count + 2)).Formula = "=SUBTOTAL(4,BI2:BI" + row_count + ")";
                            m_ds.avg_server_java_admin_server_working_set = worksheet.get_Range("BI" + (row_count + 1), "BI" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_admin_server_working_set = worksheet.get_Range("BI" + (row_count + 2), "BI" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("BM" + (row_count + 1), "BM" + (row_count + 1)).Formula = "=SUBTOTAL(1,BM2:BM" + row_count + ")";
                            worksheet.get_Range("BM" + (row_count + 2), "BM" + (row_count + 2)).Formula = "=SUBTOTAL(4,BM2:BM" + row_count + ")";
                            m_ds.avg_server_java_self_monitor_working_set = worksheet.get_Range("BM" + (row_count + 1), "BM" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_self_monitor_working_set = worksheet.get_Range("BM" + (row_count + 2), "BM" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("BJ" + (row_count + 1), "BJ" + (row_count + 1)).Formula = "=SUBTOTAL(1,BJ2:BJ" + row_count + ")";
                            worksheet.get_Range("BJ" + (row_count + 2), "BJ" + (row_count + 2)).Formula = "=SUBTOTAL(4,BJ2:BJ" + row_count + ")";
                            m_ds.avg_server_java_admin_server_working_set_peak = worksheet.get_Range("BJ" + (row_count + 1), "BJ" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_admin_server_working_set_peak = worksheet.get_Range("BJ" + (row_count + 2), "BJ" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("BN" + (row_count + 1), "BN" + (row_count + 1)).Formula = "=SUBTOTAL(1,BN2:BN" + row_count + ")";
                            worksheet.get_Range("BN" + (row_count + 2), "BN" + (row_count + 2)).Formula = "=SUBTOTAL(4,BN2:BN" + row_count + ")";
                            m_ds.avg_server_java_self_monitor_working_set_peak = worksheet.get_Range("BN" + (row_count + 1), "BN" + (row_count + 1)).Text.ToString();
                            m_ds.max_server_java_self_monitor_working_set_peak = worksheet.get_Range("BN" + (row_count + 2), "BN" + (row_count + 2)).Text.ToString();

                            //export chart pic
                            //chart1.Export(m_result_path + @"\SVR_COLLECT_chart1.jpg", "jpg", miss);
                            //chart2.Export(m_result_path + @"\SVR_COLLECT_chart2.jpg", "jpg", miss);
                            //chart3.Export(m_result_path + @"\SVR_COLLECT_chart3.jpg", "jpg", miss);
                            //chart4.Export(m_result_path + @"\SVR_COLLECT_chart4.jpg", "jpg", miss);
                        }
                        break;
                    case CommenDefine.File_Name_e.DB_COLLECT:
                        {
                            range_time = worksheet.get_Range("A2", "A" + row_count);
                            range_time.NumberFormat = "h:mm:ss.000";

                            Microsoft.Office.Interop.Excel.Range chartRange = null;
                            //ABC
                            Microsoft.Office.Interop.Excel.Chart chart1 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, B:B, C:C", Missing.Value);
                            chart1.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart1.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //ADN
                            Microsoft.Office.Interop.Excel.Chart chart2 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, D:D, N:N", Missing.Value);
                            chart2.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart2.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //AOP
                            Microsoft.Office.Interop.Excel.Chart chart3 = (Microsoft.Office.Interop.Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chartRange = worksheet.get_Range("A:A, O:O, P:P", Missing.Value);
                            chart3.ChartWizard(chartRange, Microsoft.Office.Interop.Excel.XlChartType.xlLine,
                                2, Microsoft.Office.Interop.Excel.XlRowCol.xlColumns, 1, 1, true,
                                Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                            chart3.Legend.Position = XlLegendPosition.xlLegendPositionBottom;

                            //avge and max
                            worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Formula = "=SUBTOTAL(1,B2:B" + row_count + ")";
                            worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Formula = "=SUBTOTAL(4,B2:B" + row_count + ")";
                            m_ds.avg_db_percent_processor_time = worksheet.get_Range("B" + (row_count + 1), "B" + (row_count + 1)).Text.ToString();
                            m_ds.max_db_percent_processor_time = worksheet.get_Range("B" + (row_count + 2), "B" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Formula = "=SUBTOTAL(1,C2:C" + row_count + ")";
                            worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Formula = "=SUBTOTAL(4,C2:C" + row_count + ")";
                            m_ds.avg_db_percent_mem_used = worksheet.get_Range("C" + (row_count + 1), "C" + (row_count + 1)).Text.ToString();
                            m_ds.max_db_percent_mem_used = worksheet.get_Range("C" + (row_count + 2), "C" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("D" + (row_count + 1), "D" + (row_count + 1)).Formula = "=SUBTOTAL(1,D2:D" + row_count + ")";
                            worksheet.get_Range("D" + (row_count + 2), "D" + (row_count + 2)).Formula = "=SUBTOTAL(4,D2:D" + row_count + ")";
                            m_ds.avg_db_percent_disk_time = worksheet.get_Range("D" + (row_count + 1), "D" + (row_count + 1)).Text.ToString();
                            m_ds.max_db_percent_disk_time = worksheet.get_Range("D" + (row_count + 2), "D" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("N" + (row_count + 1), "N" + (row_count + 1)).Formula = "=SUBTOTAL(1,N2:N" + row_count + ")";
                            worksheet.get_Range("N" + (row_count + 2), "N" + (row_count + 2)).Formula = "=SUBTOTAL(4,N2:N" + row_count + ")";
                            m_ds.avg_db_disk_transfer_per_sec = worksheet.get_Range("N" + (row_count + 1), "N" + (row_count + 1)).Text.ToString();
                            m_ds.max_db_disk_transfer_per_sec = worksheet.get_Range("N" + (row_count + 2), "N" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("O" + (row_count + 1), "O" + (row_count + 1)).Formula = "=SUBTOTAL(1,O2:O" + row_count + ")";
                            worksheet.get_Range("O" + (row_count + 2), "O" + (row_count + 2)).Formula = "=SUBTOTAL(4,O2:O" + row_count + ")";
                            m_ds.avg_db_sqlservr_percent_processor_time = worksheet.get_Range("O" + (row_count + 1), "O" + (row_count + 1)).Text.ToString();
                            m_ds.max_db_sqlservr_percent_processor_time = worksheet.get_Range("O" + (row_count + 2), "O" + (row_count + 2)).Text.ToString();

                            worksheet.get_Range("P" + (row_count + 1), "P" + (row_count + 1)).Formula = "=SUBTOTAL(1,P2:P" + row_count + ")";
                            worksheet.get_Range("P" + (row_count + 2), "P" + (row_count + 2)).Formula = "=SUBTOTAL(4,P2:P" + row_count + ")";
                            m_ds.avg_db_sqlservr_mem_used_mbytes = worksheet.get_Range("P" + (row_count + 1), "P" + (row_count + 1)).Text.ToString();
                            m_ds.max_db_sqlservr_mem_used_mbytes = worksheet.get_Range("P" + (row_count + 2), "P" + (row_count + 2)).Text.ToString();

                            //export chart pic
                            //chart1.Export(m_result_path + @"\DB_COLLECT_chart1.jpg", "jpg", miss);
                            //chart2.Export(m_result_path + @"\DB_COLLECT_chart2.jpg", "jpg", miss);
                            //chart3.Export(m_result_path + @"\DB_COLLECT_chart3.jpg", "jpg", miss);
                        }
                        break;
                    default:
                        break;
                }

                excel.ScreenUpdating = true;
                workbook.SaveAs(dst_file, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, miss, miss, miss, miss, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges, miss, miss, miss, miss); //另存为

                excel.Quit();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
                excel.Quit();
            }

            killexcel(excel); //结束excel进程
            return 0;
        }

        public int gen_doc(Object path)
        {
            Object miss = Missing.Value;
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document doc = word.Documents.Open(ref path, ref miss, ref miss, ref miss,
                                                                                ref miss, ref miss, ref miss, ref miss,
                                                                                ref miss, ref miss, ref miss, ref miss,
                                                                                ref miss, ref miss, ref miss, ref miss);
            
            Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbooks workbooks = excel.Workbooks;
            m_sel = doc.Application.Selection;

            //4.1	Event accumulation (eventstore, pmeventstore) 
            Microsoft.Office.Interop.Word.Table table = doc.Tables[6];
            table.Cell(2, 2).Range.Text = m_ds.avg_poll_eventstore_count;
            table.Cell(2, 3).Range.Text = m_ds.max_poll_eventstore_count;
            table.Cell(3, 2).Range.Text = m_ds.avg_poll_pmeventstore_count;
            table.Cell(3, 3).Range.Text = m_ds.max_poll_pmeventstore_count;
            insert_chart_table(6, 4, doc, workbooks, m_result_path + @"\poll_table_count.xlsx", 3);

            //4.2	Event Processing of Eventstore table
            table = doc.Tables[7];
            table.Cell(2, 2).Range.Text = m_ds.avg_poll_eventstore_produced;
            table.Cell(2, 3).Range.Text = m_ds.max_poll_eventstore_produced;
            table.Cell(3, 2).Range.Text = m_ds.avg_poll_eventstore_consumed;
            table.Cell(3, 3).Range.Text = m_ds.max_poll_eventstore_consumed;
            insert_chart_table(7, 4, doc, workbooks, m_result_path + @"\poll_table_count.xlsx", 2);

            //4.3	Event Processing of PMEventstore table
            table = doc.Tables[8];
            table.Cell(2, 2).Range.Text = m_ds.avg_poll_pmeventstore_produced;
            table.Cell(2, 3).Range.Text = m_ds.max_poll_pmeventstore_produced;
            table.Cell(3, 2).Range.Text = m_ds.avg_poll_pmeventstore_consumed;
            table.Cell(3, 3).Range.Text = m_ds.max_poll_pmeventstore_consumed;
            insert_chart_table(8, 4, doc, workbooks, m_result_path + @"\poll_table_count.xlsx", 1);

            //5.1	Agent Response Time
            table = doc.Tables[9];
            table.Cell(2, 2).Range.Text = m_ds.avg_agent_responsetime;
            table.Cell(2, 3).Range.Text = m_ds.max_agent_responsetime;
            insert_chart_table(9, 4, doc, workbooks, m_result_path + @"\PROAGENT1.xlsx", 1);

            //5.2	Console Response Time 
            table = doc.Tables[10];
            table.Cell(2, 2).Range.Text = m_ds.avg_event_console_agent;
            table.Cell(2, 3).Range.Text = m_ds.max_event_console_agent;
            table.Cell(3, 2).Range.Text = m_ds.avg_event_console_svr;
            table.Cell(3, 3).Range.Text = m_ds.max_event_console_svr;
            //insert_chart_table(11, 4, doc, workbooks, m_result_path + @"\TESTCONSOLE1_event.xlsx", 2);
            insert_chart_table(10, 6, doc, workbooks, m_result_path + @"\TESTCONSOLE1_event.xlsx", 1);

            //5.3	Command Response Time  
            table = doc.Tables[11];
            table.Cell(2, 2).Range.Text = m_ds.avg_command_responsetime;
            table.Cell(2, 3).Range.Text = m_ds.max_command_responsetime;
            insert_chart_table(11, 4, doc, workbooks, m_result_path + @"\TESTCONSOLE1_command.xlsx", 1);

            //5.4	Rule Trigger Time  
            table = doc.Tables[12];
            table.Cell(2, 2).Range.Text = m_ds.avg_trigger_time_server_time;
            table.Cell(2, 3).Range.Text = m_ds.max_trigger_time_server_time;
            insert_chart_table(12, 4, doc, workbooks, m_result_path + @"\trigger_rule.xlsx", 1);

            //6.1	ProView Server: CPU and RAM
            table = doc.Tables[13];
            table.Cell(2, 2).Range.Text = m_ds.avg_server_percent_processor_time;
            table.Cell(2, 3).Range.Text = m_ds.max_server_percent_processor_time;
            table.Cell(3, 2).Range.Text = m_ds.avg_server_percent_mem_used;
            table.Cell(3, 3).Range.Text = m_ds.max_server_percent_mem_used;
            insert_chart_table(13, 4, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 8);

            //6.2	ProView Server processes: CPU and RAM 
            table = doc.Tables[14];
            table.Cell(2, 2).Range.Text = m_ds.avg_server_agm_percent_processor_time;
            table.Cell(2, 3).Range.Text = m_ds.max_server_agm_percent_processor_time;
            table.Cell(2, 4).Range.Text = m_ds.avg_server_agm_mem_used_mbytes;
            table.Cell(2, 5).Range.Text = m_ds.max_server_agm_mem_used_mbytes;
            table.Cell(2, 6).Range.Text = m_ds.avg_server_agm_working_set;
            table.Cell(2, 7).Range.Text = m_ds.max_server_agm_working_set;
            table.Cell(2, 8).Range.Text = m_ds.avg_server_agm_working_set_peak;
            table.Cell(2, 9).Range.Text = m_ds.max_server_agm_working_set_peak;

            table.Cell(3, 2).Range.Text = m_ds.avg_server_dm_percent_processor_time;
            table.Cell(3, 3).Range.Text = m_ds.max_server_dm_percent_processor_time;
            table.Cell(3, 4).Range.Text = m_ds.avg_server_dm_mem_used_mbytes;
            table.Cell(3, 5).Range.Text = m_ds.max_server_dm_mem_used_mbytes;
            table.Cell(3, 6).Range.Text = m_ds.avg_server_dm_working_set;
            table.Cell(3, 7).Range.Text = m_ds.max_server_dm_working_set;
            table.Cell(3, 8).Range.Text = m_ds.avg_server_dm_working_set_peak;
            table.Cell(3, 9).Range.Text = m_ds.max_server_dm_working_set_peak;

            table.Cell(4, 2).Range.Text = m_ds.avg_server_pm_percent_processor_time;
            table.Cell(4, 3).Range.Text = m_ds.max_server_pm_percent_processor_time;
            table.Cell(4, 4).Range.Text = m_ds.avg_server_pm_mem_used_mbytes;
            table.Cell(4, 5).Range.Text = m_ds.max_server_pm_mem_used_mbytes;
            table.Cell(4, 6).Range.Text = m_ds.avg_server_pm_working_set;
            table.Cell(4, 7).Range.Text = m_ds.max_server_pm_working_set;
            table.Cell(4, 8).Range.Text = m_ds.avg_server_pm_working_set_peak;
            table.Cell(4, 9).Range.Text = m_ds.max_server_pm_working_set_peak;

            table.Cell(5, 2).Range.Text = m_ds.avg_server_jm_percent_processor_time;
            table.Cell(5, 3).Range.Text = m_ds.max_server_jm_percent_processor_time;
            table.Cell(5, 4).Range.Text = m_ds.avg_server_jm_mem_used_mbytes;
            table.Cell(5, 5).Range.Text = m_ds.max_server_jm_mem_used_mbytes;
            table.Cell(5, 6).Range.Text = m_ds.avg_server_jm_working_set;
            table.Cell(5, 7).Range.Text = m_ds.max_server_jm_working_set;
            table.Cell(5, 8).Range.Text = m_ds.avg_server_jm_working_set_peak;
            table.Cell(5, 9).Range.Text = m_ds.max_server_jm_working_set_peak;

            table.Cell(6, 2).Range.Text = m_ds.avg_server_fm_percent_processor_time;
            table.Cell(6, 3).Range.Text = m_ds.max_server_fm_percent_processor_time;
            table.Cell(6, 4).Range.Text = m_ds.avg_server_fm_mem_used_mbytes;
            table.Cell(6, 5).Range.Text = m_ds.max_server_fm_mem_used_mbytes;
            table.Cell(6, 6).Range.Text = m_ds.avg_server_fm_working_set;
            table.Cell(6, 7).Range.Text = m_ds.max_server_fm_working_set;
            table.Cell(6, 8).Range.Text = m_ds.avg_server_fm_working_set_peak;
            table.Cell(6, 9).Range.Text = m_ds.max_server_fm_working_set_peak;

            table.Cell(7, 2).Range.Text = m_ds.avg_server_java_admin_server_percent_processor_time;
            table.Cell(7, 3).Range.Text = m_ds.max_server_java_admin_server_percent_processor_time;
            table.Cell(7, 4).Range.Text = m_ds.avg_server_java_admin_server_mem_used_mbytes;
            table.Cell(7, 5).Range.Text = m_ds.max_server_java_admin_server_mem_used_mbytes;
            table.Cell(7, 6).Range.Text = m_ds.avg_server_java_admin_server_working_set;
            table.Cell(7, 7).Range.Text = m_ds.max_server_java_admin_server_working_set;
            table.Cell(7, 8).Range.Text = m_ds.avg_server_java_admin_server_working_set_peak;
            table.Cell(7, 9).Range.Text = m_ds.max_server_java_admin_server_working_set_peak;

            table.Cell(8, 2).Range.Text = m_ds.avg_server_java_self_monitor_percent_processor_time;
            table.Cell(8, 3).Range.Text = m_ds.max_server_java_self_monitor_percent_processor_time;
            table.Cell(8, 4).Range.Text = m_ds.avg_server_java_self_monitor_mem_used_mbytes;
            table.Cell(8, 5).Range.Text = m_ds.max_server_java_self_monitor_mem_used_mbytes;
            table.Cell(8, 6).Range.Text = m_ds.avg_server_java_self_monitor_working_set;
            table.Cell(8, 7).Range.Text = m_ds.max_server_java_self_monitor_working_set;
            table.Cell(8, 8).Range.Text = m_ds.avg_server_java_self_monitor_working_set_peak;
            table.Cell(8, 9).Range.Text = m_ds.max_server_java_self_monitor_working_set_peak;

            insert_chart_table(14, 10, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 6);
            insert_chart_table(14, 12, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 5);
            insert_chart_table(14, 14, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 4);
            insert_chart_table(14, 16, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 3);
            insert_chart_table(14, 18, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 2);
            insert_chart_table(14, 20, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 1);


            //6.3	ProView Server Resource(I/O)
            table = doc.Tables[15];
            table.Cell(2, 2).Range.Text = m_ds.avg_server_percent_disk_time;
            table.Cell(2, 3).Range.Text = m_ds.max_server_percent_disk_time;
            table.Cell(3, 2).Range.Text = m_ds.avg_server_disk_transfer_per_sec;
            table.Cell(3, 3).Range.Text = m_ds.max_server_disk_transfer_per_sec;
            insert_chart_table(15, 4, doc, workbooks, m_result_path + @"\PVSERVER_perf_counter_collect.xlsx", 7);

            //6.4	Database Server Resource
            table = doc.Tables[16];
            table.Cell(2, 2).Range.Text = m_ds.avg_db_percent_processor_time;
            table.Cell(2, 3).Range.Text = m_ds.max_db_percent_processor_time;
            table.Cell(3, 2).Range.Text = m_ds.avg_db_percent_mem_used;
            table.Cell(3, 3).Range.Text = m_ds.max_db_percent_mem_used;
            insert_chart_table(16, 4, doc, workbooks, m_result_path + @"\PVDB-perf_counter_collect.xlsx", 3);

            table = doc.Tables[17];
            table.Cell(2, 2).Range.Text = m_ds.avg_db_percent_disk_time;
            table.Cell(2, 3).Range.Text = m_ds.max_db_percent_disk_time;
            table.Cell(3, 2).Range.Text = m_ds.avg_db_disk_transfer_per_sec;
            table.Cell(3, 3).Range.Text = m_ds.max_db_disk_transfer_per_sec;
            insert_chart_table(17, 4, doc, workbooks, m_result_path + @"\PVDB-perf_counter_collect.xlsx", 2);

            table = doc.Tables[18];
            table.Cell(2, 2).Range.Text = m_ds.avg_db_sqlservr_percent_processor_time;
            table.Cell(2, 3).Range.Text = m_ds.max_db_sqlservr_percent_processor_time;
            table.Cell(3, 2).Range.Text = m_ds.avg_db_sqlservr_mem_used_mbytes;
            table.Cell(3, 3).Range.Text = m_ds.max_db_sqlservr_mem_used_mbytes;
            insert_chart_table(18, 4, doc, workbooks, m_result_path + @"\PVDB-perf_counter_collect.xlsx", 1);

            if (doc != null)
                doc.Close(ref miss, ref miss, ref miss);
            word.Quit(ref miss, ref miss, ref miss);

            excel.Quit();
            killexcel(excel);
            killword();
            return 0;
        }

        private int insert_chart_table(int table_idx, int line, Document doc, Workbooks workbooks, string file_name, int chart_idx)
        {
            if (!File.Exists(file_name))
                return -1;

            Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(file_name);
            
            Object dummy = System.Reflection.Missing.Value;
            Object what = WdGoToItem.wdGoToTable;
            Object which = WdGoToDirection.wdGoToAbsolute;
            Object count = table_idx;
            m_sel.GoTo(ref what, ref which, ref count, ref dummy);

            dummy = System.Reflection.Missing.Value;
            what = WdGoToItem.wdGoToLine;
            int lineNum = line;
            if (lineNum < 0)
                which = WdGoToDirection.wdGoToPrevious;
            else
                which = WdGoToDirection.wdGoToNext;
            count = Math.Abs(lineNum);
            m_sel.GoTo(ref what, ref which, ref count, ref dummy);

            Chart chart = (Chart)workbook.Charts[chart_idx];
            chart.ChartArea.Select();
            chart.ChartArea.Copy();
            doc.Application.Selection.PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting);
#if false
            Object link_to_file = false;
            Object save_with_document = true;
            Object range = m_sel.Range;
            InlineShape shape = doc.InlineShapes.AddPicture(pic_path.ToString(), ref link_to_file, ref save_with_document, ref range);
            shape.Width = 550f;//图片宽度
            shape.Height = 280f;//图片高度
            shape.ConvertToShape().WrapFormat.Type = WdWrapType.wdWrapSquare;//四周环绕的方式
#endif
            return 0;
        }

#if false
        private int insert_chart_page(int page_idx, int line, Document doc, Workbooks workbooks, string file_name, int chart_idx)
        {
            if (!File.Exists(file_name))
                return -1;

            Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(file_name);

            Object dummy = System.Reflection.Missing.Value;
            Object what = WdGoToItem.wdGoToPage;
            Object which = WdGoToDirection.wdGoToAbsolute;
            Object count = page_idx;
            m_sel.GoTo(ref what, ref which, ref count, ref dummy);

            dummy = System.Reflection.Missing.Value;
            what = WdGoToItem.wdGoToLine;
            int lineNum = line;
            if (lineNum < 0)
                which = WdGoToDirection.wdGoToPrevious;
            else
                which = WdGoToDirection.wdGoToNext;
            count = Math.Abs(lineNum);
            m_sel.GoTo(ref what, ref which, ref count, ref dummy);

            Chart chart = (Chart)workbook.Charts[chart_idx];
            chart.ChartArea.Select();
            chart.ChartArea.Copy();
            doc.Application.Selection.PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting);
#if false
            Object link_to_file = false;
            Object save_with_document = true;
            Object range = m_sel.Range;
            InlineShape shape = doc.InlineShapes.AddPicture(pic_path.ToString(), ref link_to_file, ref save_with_document, ref range);
            shape.Width = 550f;//图片宽度
            shape.Height = 280f;//图片高度
            shape.ConvertToShape().WrapFormat.Type = WdWrapType.wdWrapSquare;//四周环绕的方式
#endif
            return 0;
        }
#endif

        #region for kill excel process
        [DllImport("user32.dll", SetLastError = true)]
        static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
        static public void killexcel(Microsoft.Office.Interop.Excel.Application excel)
        {
            try
            {
                if (excel != null)
                {
                    int lpdwProcessId;
                    GetWindowThreadProcessId(new IntPtr(excel.Hwnd), out lpdwProcessId);
                    System.Diagnostics.Process.GetProcessById(lpdwProcessId).Kill();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("kill excel process err, message[" + ex.Message + "]");
            }
        }
        #endregion 

        #region for kill word process
        static public void killword()
        {
            try
            {
                foreach(System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName("WINWORD"))
                {
                    p.Kill();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("kill word process err, message[" + ex.Message + "]");
            }
        }
        #endregion 

        private string m_path;
        private string m_result_path;
        private Data_Set m_ds;
        private Selection m_sel;
    }

    class Data_Set
    {
        public Data_Set()
        {
            //agent
            max_agent_responsetime = "";
            avg_agent_responsetime = "";
            //command
            max_command_responsetime = "";
            avg_command_responsetime = "";
            //event
            max_event_console_agent = "";
            avg_event_console_agent = "";
            max_event_console_svr = "";
            avg_event_console_svr = "";
            //poll
            max_poll_eventstore_count = "";
            avg_poll_eventstore_count = "";
            max_poll_pmeventstore_count = "";
            avg_poll_pmeventstore_count = "";
            max_poll_eventstore_produced = "";
            avg_poll_eventstore_produced = "";
            max_poll_eventstore_consumed = "";
            avg_poll_eventstore_consumed = "";
            max_poll_pmeventstore_produced = "";
            avg_poll_pmeventstore_produced = "";
            max_poll_pmeventstore_consumed = "";
            avg_poll_pmeventstore_consumed = "";
            //trigger rule
            max_trigger_time_server_time = "";
            avg_trigger_time_server_time = "";
            //server
            max_server_percent_processor_time = "";
            avg_server_percent_processor_time = "";
            max_server_percent_mem_used = "";
            avg_server_percent_mem_used = "";
            max_server_percent_disk_time = "";
            avg_server_percent_disk_time = "";
            max_server_disk_transfer_per_sec = "";
            avg_server_disk_transfer_per_sec = "";
            max_server_agm_percent_processor_time = "";
            avg_server_agm_percent_processor_time = "";
            max_server_agm_mem_used_mbytes = "";
            avg_server_agm_mem_used_mbytes = "";
            max_server_dm_percent_processor_time = "";
            avg_server_dm_percent_processor_time = "";
            max_server_dm_mem_used_mbytes = "";
            avg_server_dm_mem_used_mbytes = "";
            max_server_pm_percent_processor_time = "";
            avg_server_pm_percent_processor_time = "";
            max_server_pm_mem_used_mbytes = "";
            avg_server_pm_mem_used_mbytes = "";
            max_server_jm_percent_processor_time = "";
            avg_server_jm_percent_processor_time = "";
            max_server_jm_mem_used_mbytes = "";
            avg_server_jm_mem_used_mbytes = "";
            max_server_fm_percent_processor_time = "";
            avg_server_fm_percent_processor_time = "";
            max_server_fm_mem_used_mbytes = "";
            avg_server_fm_mem_used_mbytes = "";
            max_server_java_admin_server_percent_processor_time = "";
            avg_server_java_admin_server_percent_processor_time = "";
            max_server_java_admin_server_mem_used_mbytes = "";
            avg_server_java_admin_server_mem_used_mbytes = "";
            max_server_java_admin_server_working_set = "";
            avg_server_java_admin_server_working_set = "";
            max_server_java_admin_server_working_set_peak = "";
            avg_server_java_admin_server_working_set_peak = "";
            max_server_java_self_monitor_percent_processor_time = "";
            avg_server_java_self_monitor_percent_processor_time = "";
            max_server_java_self_monitor_mem_used_mbytes = "";
            avg_server_java_self_monitor_mem_used_mbytes = "";
            max_server_java_self_monitor_working_set = "";
            avg_server_java_self_monitor_working_set = "";
            max_server_java_self_monitor_working_set_peak = "";
            avg_server_java_self_monitor_working_set_peak = "";
            //db
            max_db_percent_processor_time = "";
            avg_db_percent_processor_time = "";
            max_db_percent_mem_used = "";
            avg_db_percent_mem_used = "";
            max_db_percent_disk_time = "";
            avg_db_percent_disk_time = "";
            max_db_disk_transfer_per_sec = "";
            avg_db_disk_transfer_per_sec = "";
            max_db_sqlservr_percent_processor_time = "";
            avg_db_sqlservr_percent_processor_time = "";
            max_db_sqlservr_mem_used_mbytes = "";
            avg_db_sqlservr_mem_used_mbytes = "";
        }

        //agent
        public string max_agent_responsetime;
        public string avg_agent_responsetime;
        //command
        public string max_command_responsetime;
        public string avg_command_responsetime;
        //event
        public string max_event_console_agent;
        public string avg_event_console_agent;
        public string max_event_console_svr;
        public string avg_event_console_svr;
        //poll
        public string max_poll_eventstore_count;
        public string avg_poll_eventstore_count;
        public string max_poll_pmeventstore_count;
        public string avg_poll_pmeventstore_count;
        public string max_poll_eventstore_produced;
        public string avg_poll_eventstore_produced;
        public string max_poll_eventstore_consumed;
        public string avg_poll_eventstore_consumed;
        public string max_poll_pmeventstore_produced;
        public string avg_poll_pmeventstore_produced;
        public string max_poll_pmeventstore_consumed;
        public string avg_poll_pmeventstore_consumed;
        //trigger rule
        public string max_trigger_time_server_time;
        public string avg_trigger_time_server_time;
        //server
        public string max_server_percent_processor_time;
        public string avg_server_percent_processor_time;
        public string max_server_percent_mem_used;
        public string avg_server_percent_mem_used;
        public string max_server_percent_disk_time;
        public string avg_server_percent_disk_time;
        public string max_server_disk_transfer_per_sec;
        public string avg_server_disk_transfer_per_sec;
        public string max_server_agm_percent_processor_time;
        public string avg_server_agm_percent_processor_time;
        public string max_server_agm_mem_used_mbytes;
        public string avg_server_agm_mem_used_mbytes;
        public string max_server_agm_working_set;
        public string avg_server_agm_working_set;
        public string max_server_agm_working_set_peak;
        public string avg_server_agm_working_set_peak;
        public string max_server_dm_percent_processor_time;
        public string avg_server_dm_percent_processor_time;
        public string max_server_dm_mem_used_mbytes;
        public string avg_server_dm_mem_used_mbytes;
        public string max_server_dm_working_set;
        public string avg_server_dm_working_set;
        public string max_server_dm_working_set_peak;
        public string avg_server_dm_working_set_peak;
        public string max_server_pm_percent_processor_time;
        public string avg_server_pm_percent_processor_time;
        public string max_server_pm_mem_used_mbytes;
        public string avg_server_pm_mem_used_mbytes;
        public string max_server_pm_working_set;
        public string avg_server_pm_working_set;
        public string max_server_pm_working_set_peak;
        public string avg_server_pm_working_set_peak;
        public string max_server_jm_percent_processor_time;
        public string avg_server_jm_percent_processor_time;
        public string max_server_jm_mem_used_mbytes;
        public string avg_server_jm_mem_used_mbytes;
        public string max_server_jm_working_set;
        public string avg_server_jm_working_set;
        public string max_server_jm_working_set_peak;
        public string avg_server_jm_working_set_peak;
        public string max_server_fm_percent_processor_time;
        public string avg_server_fm_percent_processor_time;
        public string max_server_fm_mem_used_mbytes;
        public string avg_server_fm_mem_used_mbytes;
        public string max_server_fm_working_set;
        public string avg_server_fm_working_set;
        public string max_server_fm_working_set_peak;
        public string avg_server_fm_working_set_peak;
        public string max_server_java_admin_server_percent_processor_time;
        public string avg_server_java_admin_server_percent_processor_time;
        public string max_server_java_admin_server_mem_used_mbytes;
        public string avg_server_java_admin_server_mem_used_mbytes;
        public string max_server_java_admin_server_working_set;
        public string avg_server_java_admin_server_working_set;
        public string max_server_java_admin_server_working_set_peak;
        public string avg_server_java_admin_server_working_set_peak;
        public string max_server_java_self_monitor_percent_processor_time;
        public string avg_server_java_self_monitor_percent_processor_time;
        public string max_server_java_self_monitor_mem_used_mbytes;
        public string avg_server_java_self_monitor_mem_used_mbytes;
        public string max_server_java_self_monitor_working_set;
        public string avg_server_java_self_monitor_working_set;
        public string max_server_java_self_monitor_working_set_peak;
        public string avg_server_java_self_monitor_working_set_peak;
        //db
        public string max_db_percent_processor_time;
        public string avg_db_percent_processor_time;
        public string max_db_percent_mem_used;
        public string avg_db_percent_mem_used;
        public string max_db_percent_disk_time;
        public string avg_db_percent_disk_time;
        public string max_db_disk_transfer_per_sec;
        public string avg_db_disk_transfer_per_sec;
        public string max_db_sqlservr_percent_processor_time;
        public string avg_db_sqlservr_percent_processor_time;
        public string max_db_sqlservr_mem_used_mbytes;
        public string avg_db_sqlservr_mem_used_mbytes;
    }
}
